<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title><if condition="$project_id neq NULL">编辑项目-目的地运营集团数据管理平台<else />跟进记录-目的地运营集团数据管理平台</if></title>
<include file="Include:style" />
</head>
<body>
<if condition="$project_id eq NULL">
<include file="Include:header" />
<include file="Include:left" />
</if>
<div id="main">
	<!--搜索框-->
	<div class="crumbs">
		<if condition="$project_id eq NULL"><div class="crumbs-text">跟进记录查看</div></if>
		<div class="right">
		<if condition="get_permission('CRMG-J',NULL,6) or get_permission('CRMG-J',NULL,1) or get_permission('CRMG-J',NULL,2) or get_permission('CRMG-J',NULL,3)">
			<a href="javascript:;" class="btn btn-add ml5">添加跟进记录</a>
		</if>
		</div>
	</div>
	<div id="content">
		<if condition="$project_id neq NULL">
			<include file="Crm:crm_project_header" />
		</if>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="300px">
					周期
					<select name="year" class="form-control w100">
						<option value="-10" <if condition="$year eq -10">selected</if>>年下拉</option>
						<foreach name="year_list" item="vo">
						<option value="{$vo}" <if condition="$year eq $vo">selected</if>>{$vo}</option>
						</foreach>
					</select>
					<select name="week" class="form-control w100">
						<option value="-10" <if condition="$week eq -10">selected</if>>周期下拉</option>
						<foreach name="week_list" item="vo">
						<option value="{$vo['num']}" <if condition="$week eq $vo['num']">selected</if>>{$vo['detail']}</option>
						</foreach>
					</select>
					</td>
					<td width="100px">
						<select name="get_user" class="form-control w100">
							<option value="-10" <if condition="$get_user eq -10">selected</if>>拓展人员</option>
                            <foreach name="user_list" item="vo">
                                <option value="{$vo['id']}" <if condition="$get_user eq $vo['id']">selected</if>>{$vo['username']}</option>
                            </foreach>
                        </select>
					</td>
					<td width="200px">
						<select name="get_project" class="form-control w200">
							<option value="-10" <if condition="$get_project eq -10">selected</if>>拓展项目</option>
                            <foreach name="res_project" item="vo">
                                <option value="{$vo['project_id']}" <if condition="$get_project eq $vo['project_id']">selected</if>>{$vo['name']}</option>
                            </foreach>
                        </select>
					</td>
					<td width="100px">
						<select name="get_status" class="form-control w100">
							<option value="-10" <if condition="$get_status eq -10">selected</if>>项目阶段</option>
							<foreach name="status" item="vo">
								<if condition="$key neq 0">
									<option value="{$vo['id']}" <if condition="$get_status eq $vo['id']">selected</if>>{$vo['name']}</option>
								</if>
							</foreach>
						</select>
					</td>
					<td width="150px">联系人（电话）</td>
					<td width="100px">
						<select name="get_follow" class="form-control w100">
							<option value="-10" <if condition="$get_follow eq -10">selected</if>>跟进方式</option>
							<foreach name="follow_type" item="vo">
								<if condition="$key neq 0">
									<option value="{$vo['id']}" <if condition="$get_follow eq $vo['id']">selected</if>>{$vo['name']}</option>
								</if>
							</foreach>
						</select>
					</td>
					<td width="100px">
						<select name="get_work" class="form-control w100">
							<option value="-10" <if condition="$get_work eq -10">selected</if>>商务机会</option>
							<option value="1" <if condition="$get_work eq 1">selected</if>>顺利</option>
							<option value="2" <if condition="$get_work eq 2">selected</if>>一般</option>
							<option value="3" <if condition="$get_work eq 3">selected</if>>困难</option>
							<option value="4" <if condition="$get_work eq 4">selected</if>>不确定</option>
						</select>
					</td>
					<td width="200px">工作内容</td>
					<td width="100px">拜访时间</td>
					<td width="150px">管理</td>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td colspan="10" class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
				<tr>
					<td>{$vo['year']}年&nbsp;{$vo['week_detail']}</td>
					<td>{:get_userName($vo['add_uid'])}</td>
					<td>{$vo['project_name']}</td>
					<td>{$status[$vo['status']]['name']}</td>
					<td>{$vo['customer_info']}</td>
					<td>{$follow_type[$vo['follow_type']]['name']}</td>
					<td>{$work_chance[$vo['work_chance']]}</td>
					<td>{$vo['remark']}</td>
					<td>{$vo['visit_date']}</td>
					<td class="nowrap">
						<if condition="$vo['is_answer'] neq 2">
							<if condition="(get_permission('CRMG-J',NULL,7) and ($vo['add_uid'] eq $login_id)) or (get_permission('CRMG-J',NULL,1)) or get_permission('CRMG-J',NULL,2) or (get_permission('CRMG-J',NULL,3) and ($vo['add_uid'] eq $login_id))">
								<a href="javascript:;" class="btn-edit" mid="{$vo['record_id']}" data-toggle="tooltip" data-placement="left" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
							</if>
							<if condition="get_permission('CRMG-J',NULL,8) and ($vo['add_uid'] neq $login_id)">
								<a href="javascript:;" mid="{$vo['record_id']}" class="audit"><font color="red">批复</font></a>
							</if>
						<else />
							<font color="blue">已批复</font>
						</if>
					</td>
				</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--批复弹框-->
<div class="modal fade" id="edit-modal1">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>批复意见</strong></td>
						<td>
							<textarea id="audit_message" name="audit_message" class="form-control required-text2" style="width:100%; height:150px" autocomplete="off"></textarea>
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm" id="audit_ok">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<include file="Crm:follow_ajax" />
<include file="Crm:javascript" />
<script type="text/javascript">
$(function(){
	//批复
	$(".audit").on("click",function(){
		var modal = $("#edit-modal1"),
			mid = $(this).attr("mid");
		modal.find(".modal-header h4").text("批复");
		modal.find("#audit_ok").attr({"mid":mid});
		modal.modal();
		modal.find("#audit_message").val('');
	});
	//取消
	$("#edit-modal1").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	//批复操作
	$("#edit-modal1").find("#audit_ok").on("click",function(){
		var tag = true;
		$(".required-text2").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
 		
		if(tag){
			var mid = $(this).attr("mid"),
				audit_message = $("[name='audit_message']").val(),
				modal = $("#edit-modal1");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"id":mid,"answer":1,"answer_content":audit_message,"action":"answer"},
				url:"__APP__/Crm/follow_answer_ajax",
				success:function(data){
					success_pop(data.status);
				}
			});
		}else{
			return false;
		}
	});
	$(document).on("change","[name='year']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/project_id/{$project_id}/week/{$week}/year/"+val;
	});
	$(document).on("change","[name='week']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/project_id/{$project_id}/year/{$year}/week/"+val;
	});
	$(document).on("change","[name='get_work']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/get_work/"+val;
	});
	$(document).on("change","[name='get_follow']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/get_follow/"+val;
	});
	$(document).on("change","[name='get_status']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/get_status/"+val;
	});
	$(document).on("change","[name='get_user']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/get_user/"+val;
	});
	$(document).on("change","[name='get_project']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/follow_list/get_project/"+val;
	});
	$(document).on("focus",".required-text2",function(){
		$(this).nextAll(".error-item").hide();
	});
});
</script>
</body>
</html>
